<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>添加学生</title>
	<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
	<link rel="stylesheet" href="css/student_item.css">
	<link rel="stylesheet" href="../css/main.css">
	<link rel="stylesheet" href="./css/head.css">
</head>

<body>
	<div id="container">
		<div class="contain  ">
			<div class="header">
				<div class="header_title">添加学生</div>
				<a onclick="history.back()">
					<img src="../image/return.png" alt="" class="return">
				</a>
			</div>
			<div style="height: 40px;"></div>
			<div class="student_item_content" id="vue-root">
				<div class="info">
					<div class="hongdian"></div>
					<div class="info_text">学生姓名</div>
					<input v-model="student.name" />
				</div>
				<div class="info">
					<div class="info_text">姓名读音</div>
					<input v-model="student.voice" />
				</div>
				<div class="info">
					<div class="hongdian"></div>
					<div class="info_text">班级名称</div>
					<select id="grade" v-model="student.classesId">
						<option :value="undefined" disabled="disabled">请选择班级</option>
						<option v-for="classes in classess" v-text="classes.name" :key="classes.id" :value="classes.id">
						</option>
					</select>
				</div>
				<div class="info">
					<div class="hongdian"></div>
					<div class="info_text">绑定码</div>
					<input v-model="student.bindCode" />
				</div>
				<div class="info">
					<div class="info_text">手机号码</div>
					<input v-model="student.phone" />
				</div>
				<!-- <div class="info info2">
					<div class="info_text">绑卡</div>
					<div class="info_right">
						<div class="info_right_item_box">
							<span>关系：母亲</span>
							<span>卡号：693687</span>
							<span>删除</span>
						</div>
						<div class="addcard_btn">
							添加
						</div>
					</div>
				</div> -->
				<div class="info">
					<div class="info_text">性别</div>
					<select v-model="student.sex">
						<option :value="true">男</option>
						<option :value="false">女</option>
					</select>
				</div>

				<div class="info">
					<div class="hongdian"></div>
					<div class="info_text">就读学校</div>
					<input v-model="student.schoolName" />
				</div>

				<div class="info">
					<div class="info_text">就读年级</div>
					<input v-model="student.grade" />
				</div>
				<div class="info">
					<div class="hongdian"></div>
					<div class="info_text">学生来源</div>
					<select id="grade" v-model="student.source">
						<!-- <option :value="undefined" disabled="disabled">请选择班级</option> -->
						<option v-for="laiyuan in laiyuans" v-text="laiyuan.name" :key="laiyuan.id" :value="laiyuan.id">
						</option>
					</select>
				</div>
				<div class="info">
					<div class="info_text">推广人</div>
					<input v-model="student.promoter" />
				</div>
				<div class="info">
					<div class="info_text">咨询课程</div>
					<input v-model="student.casea" />
				</div>
				<div class="info">
					<div class="hongdian"></div>
					<div class="info_text">跟进状态</div>
					<select id="grade" v-model="student.status">
						<!-- <option :value="undefined" disabled="disabled">请选择班级</option> -->
						<option v-for="genjin in genjins" v-text="genjin.name" :key="genjin.id" :value="genjin.id">
						</option>
					</select>
				</div>
				<div class="info">
					<div class="info_text">跟进人</div>
					<input v-model="student.people" />
				</div>
				<div class="info">
					<div class="info_text">标签</div>
					<input v-model="student.label" />
				</div>
				<div class="info">
					<div class="info_text">家庭住址</div>
					<input v-model="student.address" />
				</div>
				<div class="info">
					<div class="info_text">出生日期</div>
					<input class="select_date" type="date" v-model="student.birthday">
				</div>
				<div class="info">
					<div class="info_text">入学时间</div>
					<input class="select_date" type="date" v-model="student.admissionDate">
				</div>
				<div class="info">
					<div class="info_text">毕业时间</div>
					<input class="select_date" type="date" v-model="student.graduationDatee">
				</div>
				<div class="info info2">
					<div class="info_text">备注信息</div>
					<textarea name="studentRemark" data-vv-as="备注信息" placeholder="请输入备注信息" class="layui-textarea text"
						rows="4" v-model="student.remarks"></textarea>
				</div>
				<div class="info infobtn">
					<div></div>
					<div class="button" @click="submit">添加学生
					</div>
				</div>
			</div>
		</div>
	</div>

	<script src="/scriptZIP/qs.min.js"></script>
	<script src="/scriptZIP/vue.min.js"></script>
	<script src="/scriptZIP/axios.min.js"></script>
	<script src="https://unpkg.com/element-ui/lib/index.js"></script>

	<script src="/wechat/js/wx.js"></script>
	<script src="/js/common.js"></script>

	<script>
		function store(teacher) {
			sessionStorage['hxt-teacher'] = JSON.stringify(teacher);
		}
		var app = new Vue({
			el: '#vue-root',
			data: {
				classess: [],
				teacher:{},
				student: {
					sex: false,
					source: 1,
					status: 1,
					cards:{}
				},
				laiyuans: [
					{ id: 1, name: '电话邀约' },
					{ id: 2, name: '上门咨询' },
					{ id: 3, name: '已选址未装修' },
					{ id: 4, name: '转介绍' },
					{ id: 5, name: '地推数据' },
					{ id: 6, name: '家长分享' },
					{ id: 7, name: '美团转化' },
					{ id: 8, name: '其他' },
				],
				genjins: [
					{ id: 1, name: '待跟进' },
					{ id: 2, name: '跟进中' },
					{ id: 3, name: '到访' },
					{ id: 4, name: '体验学员' },
					{ id: 5, name: '正式学员' },
					{ id: 6, name: '已失效' },
					{ id: 7, name: '无效' },
					{ id: 8, name: '其他' },
				]
			},
			created: function () {
				var teacher = getTeacher();
				axios.get('/t/classes').then(function (res) {
					this.classess = res.data;
				}.bind(this));
				if (teacher) {
					this.student.schoolId= JSON.stringify(teacher.schoolId) 
					this.teacher = teacher;
					store(this.teacher);
					return;
				}
				this.getTeacher();
			},
			methods: {
				getTeacher: function () {
					axios.get('/t/bound').then(function (res) {
						this.teacher = res.data;
						this.student.schoolId=this.teacher.schoolId
					}.bind(this));
				},
				submit: function () {
					if (!confirm('确认提交？')) return;
					var o = this.student;
					if (!o.name || !o.classesId || !o.bindCode || !o.schoolName|| !o.source|| !o.status) {
						alert('请填写完整');
						return;
					}
					axios.post('/t/student/add', this.student).then(function (res) {
						this.student = {};
						alert('提交成功');
					}.bind(this));
				},
			}
		});

	</script>

</body>

</html>